<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="__static/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">用户名</label>
        <div class="layui-input-inline">
            <input type="text" name="username" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名"
                   class="layui-input" value="{$data.username|default=''}">
            <tip>填写自己管理账号的名称。</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">性别</label>
        <div class="layui-input-inline">
            <input type="radio" name="gender" value="0"{if $data.gender eq '女'} checked{/if} title="女">
            <input type="radio" name="gender" value="1"{if $data.gender eq '男'} checked{/if} title="男">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-inline">
            <select class="role" name="role_id" lay-verify="required" lay-search="" lay-verify="required"
                    autocomplete="off">>
                <option value="">请选择角色</option>
                {volist name="datarole" id='d'}
                <option value="{$d.id}"{if $data.role_id eq $d.id} selected{/if}>{$d.name}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">是否开通主管权限</label>
        <div class="layui-input-inline">
            <input type="radio" name="is_leader" value="1"{if $data.is_leader eq 1} checked{/if} title="是">
            <input type="radio" name="is_leader" value="0"{if $data.is_leader eq 0} checked{/if} title="否">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">手机</label>
        <div class="layui-input-inline">
            <input type="number" name="mobile" lay-verify="required" lay-reqtext="手机不能为空" placeholder="请输入手机"
                   value="{$data.mobile|default=''}"
                   class="layui-input mobile">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">入职时间</label>
        <div class="layui-input-inline">
            <input type="text" name="join_time" id="join_time" placeholder="请输入入职时间" value="{$data.join_time|default=''}"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">生日</label>
        <div class="layui-input-inline">
            <input type="text" name="birthday" id="birthday" placeholder="请输入入职时间" value="{$data.birthday|default=''}"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">住址</label>
        <div class="layui-input-inline">
            <input type="email" name="address" placeholder="请输入住址" value="{$data.address|default=''}"
                   class="layui-input address">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">职级</label>
        <div class="layui-input-inline">
            <select class="role" name="grade_id" lay-verify="required" lay-search="" lay-verify="required"
                    autocomplete="off">>
                <option value="">请选择职级</option>
                {volist name="datagrade" id='d'}
                <option value="{$d.id}"{if $data.grade_id eq $d.id} selected{/if}>{$d.name}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">所属部门</label>
        <div class="layui-input-inline">
            <select class="role" name="dept_id" lay-verify="required" lay-search="" lay-verify="required"
                    autocomplete="off">>
                <option value="">请选择部门</option>
                {volist name="datadept" id='d'}
                <option value="{$d.id}"{if $data.dept_id eq $d.id} selected{/if}>{$d.name}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
    <div style="display: none;">
        <input type="hidden" name="id" value="{$data.id|default=''}">
    </div>
</div>
</div>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'laydate', 'table'], function() {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            laydate = layui.laydate,
            $ = layui.$;

        laydate.render({
            elem: '#join_time'
        });
        laydate.render({
            elem: '#birthday'
        });
        //监听提交
        form.on('submit(saveBtn)', function(data) {
            var url = '/manage/user_save';
            layer.load(2);
            $.post(url, data.field, function(d) {
                var index = layer.alert(d.msg, '', function() {
                    layer.close(index);
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                });
                layer.closeAll('loading');
            });
        });
    });


</script>
</body>
</html>